package com.atguigu.gulimall.seckill.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName RedissonConfig
 * @Description TODO
 * @Detail detail
 * @Author MyPC
 * @Date 2020/7/7
 * @Version 1.0
 */
@Configuration
public class RedissonConfig {
    /**
     * 所有的Redisson的操作都是通过RedissonClient
     * destroyMethod销毁方法，shutdown代表服务停止后销毁
     * @return
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redisson(){
        // 默认连接地址 127.0.0.1:6379
        // RedissonClient redisson = Redisson.create();
        Config config = new Config();
        config.useSingleServer().setAddress("redis://169.254.62.107:6379");
        RedissonClient redisson = Redisson.create(config);
        return redisson;
    }
}
